<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
  	<title>添加或者修改菜肴</title>
  	<%@ include file="../include/jsCss.jsp" %> 
  </head>
  <body>
  	<form action="mealmenu!mealMenuSaveOrUpdate.html" method="post" id="frmMealMenu">
		菜肴信息
		<hr/>
		<table>
			<tr>
				<td>图片</td>
				<td><iframe src="${webUrl }/images!imageUpload2.html?width=300&height=400" width="100%" height="250" scrolling="no" frameborder="0" style="border: 0px;"></iframe> </td>
			</tr>
			<tr>
				<td>菜名</td>
				<td>
					<input type="text" name="menuName" value="${mealMenuDto.menuName }" onblur="javascript:valMenuName();"/>
					<span id="menuNameShow"></span>
					<input type="hidden" name="restaurantId" value="${mealMenuDto.restaurantId }"/>
					<input type="hidden" name="id" value="${mealMenuDto.id }"/>
			    </td>
			</tr>
			<tr>
				<td>价格</td>
				<td><input type="text" name="price" value="${mealMenuDto.price }" onblur="javascript:valPrice();"/> 元
					<span id="priceShow"></span>
				</td>
			</tr>
			<tr>
				<td>编号</td>
				<td><input type="text" name="mealMenuId" value="${mealMenuDto.mealMenuId }" onblur="javascript:valMenuId();"/> 
					<span id="menuId"></span>
				</td>
			</tr>
			<tr>
				<td>排序号</td>
				<td><input type="text" name="orderBy" value="${mealMenuDto.orderBy }"/> </td>
			</tr>
			<tr>
				<td>菜肴类别</td>
				<td>
					<select name="menuTypeId">
						<option value="0">-----</option>
						<s:iterator value="mealMenuTypeList">
							<s:if test="mealMenuDto.menuTypeId == id">
								<option value="${id }" selected="selected">${menuTypeName}</option>
							</s:if>
							<s:else>
								<option value="${id }">${menuTypeName }</option>
							</s:else>
						</s:iterator>
					</select>
				</td>
			</tr>
			<tr>
				<td>口味</td>
				<td>
					<select name="taste">
						<option value="0">-----</option>
						<option value="0">香辣</option>
						<option value="1">香辣(可选)</option>
						<option value="2">不辣</option>
					</select>
				</td>
			</tr>
			<tr>
				<td align="right"><input type="checkbox" name="isRecommend"/> </td>
				<td>是否推荐</td>
			</tr>
			<tr>
				<td>状态</td>
				<td>
					<select name="status">
						<s:if test="mealMenuDto.status == 0"> 
							<option value="0" selected="selected">有效</option>
						</s:if>
						<s:else>
							<option value="0">有效</option>
						</s:else>
						<s:if test="mealMenuDto.status == 1">
							<option value="1" selected="selected">无效</option>
						</s:if>
						<s:else>
							<option value="1">无效</option>
						</s:else>
					</select>
				</td>
			</tr>
			<tr>
				<td>介绍</td>
				<td><textarea rows="5" cols="25" name="introduce">${mealMenuDto.introduce }</textarea></td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="button" value="保存" onclick="javascript:btnMealMenu();"/>
				</td>
			</tr>
		</table>
	</form>
  </body>
</html>
<script type="text/javascript">
	
	function btnMealMenu(){
		var name = $("input[name='menuName']").val();
		var prices = $("input[name='price']").val();
		var menuId = $("input[name='mealMenuId']").val();
		
		//菜名
		if($.trim(name) == ''){
			$("#menuNameShow").show();
			$("#menuNameShow").text("请输入菜名");
			$("#menuNameShow").css('color','red');
			return;
		}else{
			$("#menuNameShow").hide();
		}
		
		//价格
		if($.trim(prices) == ''){
			$("#priceShow").show();
			$("#priceShow").text("(请输入价格)");
			$("#priceShow").css('color','red');
			return;
		}else{
			if(isNaN($.trim(prices))){
				$("#priceShow").show();
				$("#priceShow").text("(请输入数字)");
				$("#priceShow").css('color','red');
			}else{
				$("#priceShow").hide();
			}
		}
		
		//编号
		if($.trim(menuId) == ''){
			$("#menuId").show();
			$("#menuId").text("请输入编号");
			$("#menuId").css('color','red');
			return;
		}else{
			$("#menuId").hide();
		}
		
		$("#frmMealMenu").submit();
	}

	//菜名
	function valMenuName(){
		var name = $("input[name='menuName']").val();
		
		if($.trim(name) == ''){
			$("#menuNameShow").show();
			$("#menuNameShow").text("请输入菜名");
			$("#menuNameShow").css('color','red');
		}else{
			$("#menuNameShow").hide();
		}
	}
	
	//价格
	function valPrice(){
		var prices = $("input[name='price']").val();
		
		if($.trim(prices) == ''){
			$("#priceShow").show();
			$("#priceShow").text("(请输入价格)");
			$("#priceShow").css('color','red');
		}else{
			if(isNaN($.trim(prices))){
				$("#priceShow").show();
				$("#priceShow").text("(请输入数字)");
				$("#priceShow").css('color','red');
			}else{
				$("#priceShow").hide();
			}
		}
	}
	
	//编号
	function valMenuId(){
		var menuId = $("input[name='mealMenuId']").val();
		if($.trim(menuId) == ''){
			$("#menuId").show();
			$("#menuId").text("请输入编号");
			$("#menuId").css('color','red');
		}else{
			$("#menuId").hide();
		}
	}
</script>